import 'package:flutter/material.dart';
import 'package:hello_flutter/demo/chopper_demo/data/post_api_service.dart';
import 'package:logging/logging.dart';
import 'package:provider/provider.dart';
import './page/home_page.dart';

void main() {
  _setupLogging();
  runApp(ChopperTestApp());
}

void _setupLogging() {
  Logger.root.level = Level.ALL;
  Logger.root.onRecord.listen((record) {
    print('日志记录：${record.level.name}:${record.time}:${record.message}');
  });
}

class ChopperTestApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Provider(
      child: MaterialApp(
        debugShowCheckedModeBanner: false,
        home: HomePage(),
      ),
      builder: (_) => PostApiService.create(),
      dispose: (_, PostApiService postService) => postService.client.dispose(),
    );
  }
}
